@using Microsoft.AspNetCore.Mvc.TagHelpers
@using BTCPayServer.Client
@model List<BTCPayServer.Data.FormData>
@{
    ViewData.SetLayoutModel(new LayoutModel(nameof(StoreNavPages.Forms), StringLocalizer["Forms"]).SetCategory(WellKnownCategories.Store));
    var storeId = Context.GetCurrentStoreId();
}

<div class="sticky-header">
    <h2>
        <span>@ViewData["Title"]</span>
        <a href="https://docs.btcpayserver.org/Forms" target="_blank" rel="noreferrer noopener" title="@StringLocalizer["More information..."]">
            <vc:icon symbol="info" />
        </a>
    </h2>
	<a id="page-primary" asp-action="Create" asp-route-storeId="@storeId" class="btn btn-primary mt-3 mt-sm-0" role="button" permission="@Policies.CanModifyStoreSettings" text-translate="true">
        Create Form
    </a>
</div>
<partial name="_StatusMessage" />

<div class="row">
    <div class="col-xxl-constrain col-xl-10">
        @if (Model.Any())
        {
            <div class="table-responsive-md mt-0">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th text-translate="true">Name</th>
                            <th text-translate="true" class="actions-col" permission="@Policies.CanModifyStoreSettings">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr>
                                <td>
                                    <a asp-action="Modify" asp-route-storeId="@item.StoreId" asp-route-id="@item.Id" id="Edit-@item.Name" permission="@Policies.CanModifyStoreSettings">@item.Name</a>
                                    <a asp-action="ViewPublicForm" asp-route-formId="@item.Id" id="View-@item.Name" not-permission="@Policies.CanModifyStoreSettings">@item.Name</a>
                                </td>
                                <td class="actions-col" permission="@Policies.CanModifyStoreSettings">
                                    <a asp-action="Remove" asp-route-storeId="@item.StoreId" asp-route-id="@item.Id" id="Remove-@item.Id" data-bs-toggle="modal" data-bs-target="#ConfirmModal"  data-confirm-input="@StringLocalizer["Delete"]" text-translate="true">Remove</a> -
                                    <a asp-action="ViewPublicForm" asp-route-formId="@item.Id" id="View-@item.Name" text-translate="true">View</a>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        }
        else
        {
            <p class="text-secondary" text-translate="true">
                There are no forms yet.
            </p>
        }
    </div>
</div>

<partial name="_Confirm" model="@(new ConfirmModel("Delete form", "This form will be removed from this store.", StringLocalizer["Delete"]))" permission="@Policies.CanModifyStoreSettings" />
